home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 May / Ahoy_Magazine_87-05_1987_Double_L_Side_A.d64 / Power Product 2 (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  618b  |  22 lines

  1. 0 rem << cd41-8 >>
  2. 1 rem ==================================
  3. 2 rem    commodares problem #37-3 :
  4. 3 print"[147]power product"
  5. 4 rem    solution by
  6. 5 rem    scott duncan
  7. 6 rem ==================================
  8. 9 t0=ti
  9. 10 dim p(99):for x=10 to 90 step10:p(x)=1:a=int(x/10)
  10. 20 for y=1 to 9:p(x+y)=p(x+(y-1))*a:next:next
  11. 30 for l=1 to 99:if p(l)>9999 goto 100
  12. 40 for m=0 to l
  13. 50 q=p(l)*p(m) : if q>9999 goto 100
  14. 60 j=l*100+m : k=m*100+l
  15. 70 if q=j then a=l:c=m:gosub 120
  16. 80 if q=k then a=m:c=l:gosub 120
  17. 90 next m
  18. 100 next l
  19. 110 print "total " t : print (ti-t0)/60 "seconds": end
  20. 120 a$=str$(a+1000) : c$=str$(c+1000) : t=t+1
  21. 130 print q"= "mid$(a$,4,1) "^" mid$(a$,5)" * "mid$(c$,4,1)"^"mid$(c$,5):return
  22.